import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:yp/config/config.dart';

import 'logic.dart';
import 'state.dart';

class GongDanPage extends StatelessWidget {
  final GongDanLogic logic = Get.put(GongDanLogic());
  final GongDanState state = Get.find<GongDanLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Config.mainColor,
        title: Text(
          "工单详情",
          style: TextStyle(
            color: Colors.white,
            fontSize: 34.sp,
          ),
        ),
        centerTitle: true,
        elevation: 0,
      ),
      body: GetBuilder<GongDanLogic>(
        builder: (logic) {
          return state.orderList != null && state.orderList.length == 0
              ? Container(
                  child: Center(
                    child: Text("系统未找到该外部单号或销售单号相关工单"),
                  ),
                )
              : state.orderList == null
                  ? Container()
                  : ListView.builder(
                      itemBuilder: (ctx, i) {
                        var item = state.orderList[i];
                        return Row(
                          mainAxisAlignment: MainAxisAlignment.start,
                          children: [
                            Container(
                              width: 100.w,
                              child: Text(item["stat"]),
                            ),
                            Container(
                              width: 300.w,
                              child: Text(item["orderNo"]),
                            ),
                            Expanded(
                              child: Text(
                                item["itemName"],
                              ),
                            ),
                          ],
                        );
                      },
                      itemCount: state.orderList.length,
                    );
        },
      ),
    );
  }
}
